package org.linlinjava.litemall.db.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;

public class LumiereSubscribe {
    public static final Boolean IS_DELETED = Deleted.IS_DELETED.value();

    public static final Boolean NOT_DELETED = Deleted.NOT_DELETED.value();

    private Integer id;

    private String name;

    private String picture;

    private String timeRanges;

    private Boolean autoSub;

    private Integer[] transportType;

    private Byte orderRule;

    private Byte useRange;

    private Integer[] shopIds;

    private Integer status;

    private LocalDateTime addTime;

    private Integer addUserId;

    private LocalDateTime updateTime;

    private Integer updateUserId;

    private Boolean deleted;

    private String picUrl;

    private Integer[] regionIds;

    @TableField("`desc`")
    private String desc;

    private LocalDateTime startTime;

    private LocalDateTime endTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public String getTimeRanges() {
        return timeRanges;
    }

    public void setTimeRanges(String timeRanges) {
        this.timeRanges = timeRanges;
    }

    public Boolean getAutoSub() {
        return autoSub;
    }

    public void setAutoSub(Boolean autoSub) {
        this.autoSub = autoSub;
    }

    public Integer[] getTransportType() {
        return transportType;
    }

    public void setTransportType(Integer[] transportType) {
        this.transportType = transportType;
    }

    public Byte getOrderRule() {
        return orderRule;
    }

    public void setOrderRule(Byte orderRule) {
        this.orderRule = orderRule;
    }

    public Byte getUseRange() {
        return useRange;
    }

    public void setUseRange(Byte useRange) {
        this.useRange = useRange;
    }

    public Integer[] getShopIds() {
        return shopIds;
    }

    public void setShopIds(Integer[] shopIds) {
        this.shopIds = shopIds;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }

    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public Integer getAddUserId() {
        return addUserId;
    }

    public void setAddUserId(Integer addUserId) {
        this.addUserId = addUserId;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getUpdateUserId() {
        return updateUserId;
    }

    public void setUpdateUserId(Integer updateUserId) {
        this.updateUserId = updateUserId;
    }

    public void andLogicalDeleted(boolean deleted) {
        setDeleted(deleted ? Deleted.IS_DELETED.value() : Deleted.NOT_DELETED.value());
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public Integer[] getRegionIds() {
        return regionIds;
    }

    public void setRegionIds(Integer[] regionIds) {
        this.regionIds = regionIds;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }



    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", IS_DELETED=").append(IS_DELETED);
        sb.append(", NOT_DELETED=").append(NOT_DELETED);
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", picture=").append(picture);
        sb.append(", timeRanges=").append(timeRanges);
        sb.append(", autoSub=").append(autoSub);
        sb.append(", transportType=").append(transportType);
        sb.append(", orderRule=").append(orderRule);
        sb.append(", useRange=").append(useRange);
        sb.append(", shopIds=").append(shopIds);
        sb.append(", status=").append(status);
        sb.append(", addTime=").append(addTime);
        sb.append(", addUserId=").append(addUserId);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", updateUserId=").append(updateUserId);
        sb.append(", deleted=").append(deleted);
        sb.append(", picUrl=").append(picUrl);
        sb.append(", regionIds=").append(regionIds);
        sb.append(", desc=").append(desc);
        sb.append(", startTime=").append(startTime);
        sb.append(", endTime=").append(endTime);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        LumiereSubscribe other = (LumiereSubscribe) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getPicture() == null ? other.getPicture() == null : this.getPicture().equals(other.getPicture()))
            && (this.getTimeRanges() == null ? other.getTimeRanges() == null : this.getTimeRanges().equals(other.getTimeRanges()))
            && (this.getAutoSub() == null ? other.getAutoSub() == null : this.getAutoSub().equals(other.getAutoSub()))
            && (Arrays.equals(this.getTransportType(), other.getTransportType()))
            && (this.getOrderRule() == null ? other.getOrderRule() == null : this.getOrderRule().equals(other.getOrderRule()))
            && (this.getUseRange() == null ? other.getUseRange() == null : this.getUseRange().equals(other.getUseRange()))
            && (Arrays.equals(this.getShopIds(), other.getShopIds()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
            && (this.getAddUserId() == null ? other.getAddUserId() == null : this.getAddUserId().equals(other.getAddUserId()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getUpdateUserId() == null ? other.getUpdateUserId() == null : this.getUpdateUserId().equals(other.getUpdateUserId()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
            && (this.getPicUrl() == null ? other.getPicUrl() == null : this.getPicUrl().equals(other.getPicUrl()))
            && (Arrays.equals(this.getRegionIds(), other.getRegionIds()))
            && (this.getDesc() == null ? other.getDesc() == null : this.getDesc().equals(other.getDesc()))
            && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
            && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getPicture() == null) ? 0 : getPicture().hashCode());
        result = prime * result + ((getTimeRanges() == null) ? 0 : getTimeRanges().hashCode());
        result = prime * result + ((getAutoSub() == null) ? 0 : getAutoSub().hashCode());
        result = prime * result + (Arrays.hashCode(getTransportType()));
        result = prime * result + ((getOrderRule() == null) ? 0 : getOrderRule().hashCode());
        result = prime * result + ((getUseRange() == null) ? 0 : getUseRange().hashCode());
        result = prime * result + (Arrays.hashCode(getShopIds()));
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
        result = prime * result + ((getAddUserId() == null) ? 0 : getAddUserId().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getUpdateUserId() == null) ? 0 : getUpdateUserId().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        result = prime * result + ((getPicUrl() == null) ? 0 : getPicUrl().hashCode());
        result = prime * result + (Arrays.hashCode(getRegionIds()));
        result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode());
        result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
        result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
        return result;
    }

    public enum Deleted {
        NOT_DELETED(new Boolean("0"), "未删除"),
        IS_DELETED(new Boolean("1"), "已删除");

        private final Boolean value;

        private final String name;

        Deleted(Boolean value, String name) {
            this.value = value;
            this.name = name;
        }

        public Boolean getValue() {
            return this.value;
        }

        public Boolean value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }
    }

    public enum Column {
        id("id", "id", "INTEGER", false),
        name("name", "name", "VARCHAR", true),
        picture("picture", "picture", "VARCHAR", false),
        timeRanges("time_ranges", "timeRanges", "VARCHAR", false),
        autoSub("auto_sub", "autoSub", "BIT", false),
        transportType("transport_type", "transportType", "VARCHAR", false),
        orderRule("order_rule", "orderRule", "TINYINT", false),
        useRange("use_range", "useRange", "TINYINT", false),
        shopIds("shop_ids", "shopIds", "VARCHAR", false),
        status("status", "status", "INTEGER", true),
        addTime("add_time", "addTime", "TIMESTAMP", false),
        addUserId("add_user_id", "addUserId", "INTEGER", false),
        updateTime("update_time", "updateTime", "TIMESTAMP", false),
        updateUserId("update_user_id", "updateUserId", "INTEGER", false),
        deleted("deleted", "deleted", "BIT", false),
        picUrl("pic_url", "picUrl", "VARCHAR", false),
        regionIds("region_ids", "regionIds", "VARCHAR", false),
        desc("desc", "desc", "VARCHAR", true);

        private static final String BEGINNING_DELIMITER = "`";

        private static final String ENDING_DELIMITER = "`";

        private final String column;

        private final boolean isColumnNameDelimited;

        private final String javaProperty;

        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }
    }
}